Mcdc test coverage - part 7 - #11222
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request extends the ISO 26262 MC/DC coverage suite across wolfCrypt and (newly) the TLS 1.3 engine, primarily by adding/expanding API-level tests and unit MC/DC white-box drivers, plus a small set of correctness fixes in core crypto code discovered during coverage work.
Changes:
- Expand TLS 1.3 and wolfCrypt MC/DC coverage via new
tests/api/*cases and manytests/unit-mcdc/*white-box supplements. - Fix correctness issues found during coverage: XMSS exhausted-index validity, DSA mp_init_multi() failure cleanup handling, and AES key-wrap test alignment.
- Update harness/docs glue (
tests/include.am,tests/api/include.am,tests/api.c) to register/distribute new tests and white-box sources.
Reviewed changes
Copilot reviewed 127 out of 127 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wolfssl/internal.h | Make ChaCha20-Poly1305 header visible whenever suites are built; adjust PEM error-reason comparisons to use WC_NO_ERR_TRACE. |
| wolfcrypt/test/test.c | Fix AES key-wrap _ex test to use properly aligned Aes storage on-stack. |
| wolfcrypt/src/wc_xmss_impl.c | Fix XMSS index validity checks to avoid wrap-around at exhausted-key markers. |
| wolfcrypt/src/dsa.c | Map mp_init_multi() failures to MP_INIT_E and gate cleanup accordingly. |
| tests/unit-mcdc/test_xmss_hash_fault_whitebox.c | Update white-box notes/text to suite/harness terminology. |
| tests/unit-mcdc/test_xmss_fault_whitebox.c | Update comments/notes to suite/harness terminology. |
| tests/unit-mcdc/test_wolfentropy_whitebox.c | Add SHA3-256 interposer and new startup-noise failure vector for MC/DC; update harness wording. |
| tests/unit-mcdc/test_wc_port_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_wc_mlkem_poly_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_wc_mldsa_whitebox.c | Add CheckKey range-row driver; ensure unbuffered stdout; comment wording updates. |
| tests/unit-mcdc/test_wc_lms_impl_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_wc_lms_impl_whitebox_gap.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_wc_encrypt_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_tsp_whitebox.c | Comment wording updates for uncovered-condition report + harness terminology. |
| tests/unit-mcdc/test_tsp_fault_whitebox.c | Add vectors around TspResponse_Verify cert operand; comment wording updates. |
| tests/unit-mcdc/test_tfm_whitebox.c | Fix/clarify MC/DC rationale notes; ensure unbuffered stdout; comment wording updates. |
| tests/unit-mcdc/test_srp_whitebox.c | New SRP hash-fault white-box supplement to close one open condition. |
| tests/unit-mcdc/test_sp_x86_64_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_sp_int_whitebox.c | Ensure settings loaded before deterministic RNG header; add pinned seed and new closure path; comment wording updates. |
| tests/unit-mcdc/test_sp_int_fault_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_sp_fault_common.h | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_sp_crafted_common.h | Broaden asm-backend gating list; comment wording updates. |
| tests/unit-mcdc/test_sp_cortexm_whitebox.c | Update lane description wording. |
| tests/unit-mcdc/test_sp_cortexm_fault_whitebox.c | New Cortex-M SP heap-fault white-box supplement via new lane mechanism. |
| tests/unit-mcdc/test_sp_cortexm_crafted_whitebox.c | New Cortex-M SP crafted-input white-box supplement via new lane mechanism. |
| tests/unit-mcdc/test_sp_c32_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_sp_armthumb_whitebox.c | Add shared crafted-input driver include and alloc fault include; invoke shared vectors. |
| tests/unit-mcdc/test_sp_arm64_whitebox.c | Add shared crafted-input driver include and alloc fault include; invoke shared vectors. |
| tests/unit-mcdc/test_sp_arm32_whitebox.c | Add shared crafted-input driver include and alloc fault include; invoke shared vectors. |
| tests/unit-mcdc/test_sp_arm_fault_common.h | Comment wording updates for suite/harness terminology. |
| tests/unit-mcdc/test_slhdsa_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_slhdsa_hash_fault_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_signature_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_she_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_sha256_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_sakke_fault_whitebox.c | Add interposition-driven coverage for retry-loop and helper reductions; comment wording updates. |
| tests/unit-mcdc/test_rsa_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_rsa_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_random_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_random_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_pwdbased_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_puf_gf_whitebox.c | New PUF GF(2^7) helper white-box supplement. |
| tests/unit-mcdc/test_poly1305_whitebox.c | Comment wording updates for module registry / harness terminology. |
| tests/unit-mcdc/test_pkcs7_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_pkcs7_mutate_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_pkcs7_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_pkcs7_arg_whitebox.c | Add EncodeContentStream pad-gate driver; add unreachable rationale note; comment wording updates. |
| tests/unit-mcdc/test_pkcs12_whitebox.c | Comment wording updates for suite terminology; small note updates. |
| tests/unit-mcdc/test_pkcs12_parse_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_pkcs12_fault_whitebox.c | Comment wording updates for suite/harness terminology. |
| tests/unit-mcdc/test_mlkem_poly_hash_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_mlkem_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_mldsa_hash_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_mldsa_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_memory_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_logging_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_lms_hash_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_kdf_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_kdf_hash_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_integer_whitebox.c | Comment wording updates for suite/harness terminology. |
| tests/unit-mcdc/test_integer_fault_whitebox.c | Comment wording updates for suite/harness terminology. |
| tests/unit-mcdc/test_hpke_fault_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_frodokem_mat_hash_fault_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_frodokem_mat_fault_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_frodokem_fault_common.h | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_frodokem_cryptocb_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_falcon_whitebox.c | Update residual notes to refer to exclusion record; comment wording updates. |
| tests/unit-mcdc/test_ed448_whitebox.c | Comment wording updates for suite/harness terminology. |
| tests/unit-mcdc/test_ed448_hash_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_ed25519_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_ed25519_hash_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_ecc_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_ecc_fault_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_dsa_fault_whitebox.c | Add targeted fault hooks/vectors for DSA init/cleanup and MEMORY_E path; comment wording updates. |
| tests/unit-mcdc/test_dh_fault_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/test_curve25519_whitebox.c | Add RNG interposer to close blinding rz rejection-loop condition; ensure unbuffered stdout. |
| tests/unit-mcdc/test_cmac_whitebox.c | Comment wording updates for harness terminology. |
| tests/unit-mcdc/test_chacha20_poly1305_whitebox.c | Comment wording updates for exclusion record / harness terminology. |
| tests/unit-mcdc/test_chacha_whitebox.c | Comment wording updates for module registry / harness terminology. |
| tests/unit-mcdc/test_asn_whitebox.c | Ensure unbuffered stdout; comment wording updates for suite terminology. |
| tests/unit-mcdc/test_asn_keys_whitebox.c | Add additional MC/DC vectors for PKCS8/PBES encode and ECC key DER branches. |
| tests/unit-mcdc/test_aes_whitebox.c | Comment wording updates for suite terminology. |
| tests/unit-mcdc/README.md | Update documentation to “suite/harness” terminology and clarify build contract. |
| tests/unit-mcdc/mcdc_seed_rng.h | Ensure settings included before feature probing; update harness terminology. |
| tests/unit-mcdc/mcdc_fault_mutex.h | Comment wording updates for suite terminology. |
| tests/unit-mcdc/mcdc_fault_mpint.h | Comment wording updates for suite terminology. |
| tests/unit-mcdc/mcdc_fault_mp.h | Comment wording updates for suite terminology. |
| tests/unit-mcdc/mcdc_fault_hash.h | Comment wording updates for suite terminology. |
| tests/unit-mcdc/mcdc_fault_alloc.h | Comment wording updates for suite terminology. |
| tests/unit-mcdc/mcdc_der_edit.h | Comment wording updates for suite terminology. |
| tests/include.am | Add new unit-mcdc sources to EXTRA_DIST; update suite wording. |
| tests/api/test_wolfmath.c | Comment wording updates for harness terminology. |
| tests/api/test_tls13.c | Add additional TLS 1.3 API guard acceptance vectors and related coverage notes. |
| tests/api/test_tls13_features.h | New header declaring TLS 1.3 feature coverage tests and registration macro. |
| tests/api/test_tls13_bounds.h | New header declaring TLS 1.3 bounds/fragmentation tests and registration macro. |
| tests/api/test_sakke.c | Comment wording update. |
| tests/api/test_rsa.c | Comment wording update. |
| tests/api/test_random.c | Comment wording updates for uncovered-condition report / suite terminology. |
| tests/api/test_port.c | Comment wording update. |
| tests/api/test_poly1305.c | Comment wording update. |
| tests/api/test_mlkem.c | Comment wording update. |
| tests/api/test_mldsa.c | Comment wording update. |
| tests/api/test_kdf.c | Comment wording updates for suite terminology. |
| tests/api/test_hmac.c | Comment wording updates for suite terminology. |
| tests/api/test_hash.c | Comment wording update. |
| tests/api/test_dh.c | Comment wording update. |
| tests/api/test_chacha.c | Comment wording update. |
| tests/api/test_aes.c | Comment wording update. |
| tests/api/include.am | Register new TLS 1.3 API test sources and distribute new headers. |
| tests/api.c | Include and register new TLS 1.3 bounds/features test groups. |
| tests/api/test_tls13_bounds.c | New TLS 1.3 bounds/fragmentation API tests (registered in build). |
| tests/api/test_tls13_features.c | New TLS 1.3 feature-combination API tests (registered in build). |
| tests/unit-mcdc/test_lms_bds_whitebox.c | New LMS BDS white-box supplement (distributed via EXTRA_DIST). |
| tests/unit-mcdc/test_tls13_whitebox.c | New TLS 1.3 MC/DC white-box supplement (distributed via EXTRA_DIST). |
| tests/unit-mcdc/test_tls13_null_whitebox.c | New TLS 1.3 NULL/guard-focused white-box supplement (distributed via EXTRA_DIST). |
| tests/unit-mcdc/test_wolfmath_whitebox.c | New wolfmath MC/DC white-box supplement (distributed via EXTRA_DIST). |
Suppressed comments (1)
wolfcrypt/src/dsa.c:441
- wc_MakeDsaParameters() maps a failed mp_init_multi() to MP_INIT_E, but the cleanup logic checks for WC_NO_ERR_TRACE(MP_INIT_E). Under WOLFSSL_DEBUG_TRACE_ERROR_CODES, assigning plain MP_INIT_E can make the cleanup think init succeeded and call mp_clear() on objects that mp_init_multi() never constructed.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f4bafda to
3d4a6fe
Compare
|
Retest this please. |
8a6f76d to
4173cb8
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11222
Scan targets checked: wolfcrypt-bugs, wolfcrypt-port-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
…_init_multi never built
…ards from the white-box
…ility Adds the HAVE_TLS_EXTENSIONS, per-extension and WOLFSSL_NO_TLS12 terms the bodies need, and releases the SNI list a test detaches from its extension.
…y unused Their callers sit behind differing feature guards, so any configuration can compile in none of them.
Also guards the sni free helper on HAVE_SNI and gives the request-direction key share entry a public key before it is written.
EXPECT_DECLS records the failure and carries on, so the field access ran on a null pointer.
The test builds a server context but its response-direction sections need a client one; guarding the sections keeps the server half running.
A build without a client compiles out its only user.
ExpectNotNull() does not assign once an earlier expectation has failed, so the variable can be read undefined. Also moves the server-context helper's declarations to the top of its block.
…he paths wolfSSL_SetAllocators is defined only under USE_WOLFSSL_MEMORY, the session ticket members only under HAVE_SESSION_TICKET, and the ffdhe bookkeeping that makes an unsupported group parse cleanly is compiled out without DH, TLS 1.2 or the server.
The tests/unit-mcdc white-box translation units are not part of unit.test, so nothing in CI builds or runs them. This builds --enable-all once and runs the subset that works against it, failing only when one that passed before stops.
Cover the RFC 4518 Sec. 2.2 ranges that map a code point to nothing, the EN QUAD to HAIR SPACE block, UTF-16 surrogate pairs and the code units just above the surrogate block, values whose tag is not a character string type, and the AttributeTypeAndValue argument validation in MatchDirAttr().
The chain check tells RSASSA-PSS apart from SHA-1 through the algorithm parameters rather than the signature OID, which no existing case covers.
Adds the ecdsa-with-SHA1, dsa-with-sha1 and RSASSA-PSS signature algorithm vectors, the certificate and chain presence guards of CheckCertChainSigAlgo(), and the allocation failure SendTls13Certificate() has to pass through.
… stack wc_AesNew accounts for the type's alignment, which was the reason for the local; the local was large enough to push the function's frame past 4096 bytes in some configurations.
The caller-supplied Aes was moved to wc_AesNew() to keep aeskeywrap_test() under the 4096 byte frame limit, but wc_AesNew() allocates with XMALLOC and so only guarantees the platform malloc alignment: 8 bytes on 32-bit targets, against the 16 that struct Aes asks for through its ALIGN16 members. On 32-bit ARM built for armv8-a+crypto, wc_AesSetIV() lowers to an alignment-qualified NEON store, which faults on an 8-aligned object. Move the block to its own function instead. The Aes goes back to a local, so the compiler gives it the type's alignment, and the frame limit is per function, so aeskeywrap_test() stays within it.
The previous commit moved the caller-supplied Aes into its own function to keep the frame down, which does not work: with --enable-aesgcm=table the GCM tables inside struct Aes are 4096 bytes on their own, so no function can hold one as a local under the -Wframe-larger-than limits CI enforces (4096 in the aes config set, 2048 in the small-stack and linuxkm workflows). -Wstack-usage counts the whole call chain in any case, so splitting the function would not have helped even had the frame fit. Plain heap allocation does not work either. The type asks for 16 byte alignment through its ALIGN16 members, while XMALLOC -- and so wc_AesNew() -- only guarantees 8 on 32-bit targets, and wc_AesSetIV() lowers to an alignment-qualified NEON store when building for armv8-a+crypto. Allocate with headroom and align by hand, keeping the base pointer for XFREE. That satisfies both constraints: the frame holds only pointers, and the object meets the alignment its type declares.
… 32-bit ARM struct Aes carries ALIGN16 members, so _Alignof(Aes) is 16 whenever WOLFSSL_USE_ALIGN is set, which is the default on ARM: --enable-aligndata defaults to yes, and WOLFSSL_ARMASM defines WOLFSSL_USE_ALIGN unconditionally. The objects are heap allocated with XMALLOC on the TLS data path -- SetKeys() does so for every AES suite, as do dtls13.c, internal.c and kdf.c. On 32-bit targets malloc only guarantees 8 byte alignment, so an object can come back 8-aligned while its type claims 16. That is undefined, and observable: wc_AesSetIV() lowers to an alignment-qualified NEON store on armv8-a+crypto, which faults. Observed on arm-linux-gnueabihf under qemu-arm with --enable-armasm: a TLS 1.3 AES-CCM handshake took SIGBUS in key setup, with the encrypt object 16-aligned and the decrypt object 8-aligned. Which object lands where follows from allocation history, so the fault migrates between call sites rather than belonging to any one of them. Cap the request at what the allocator guarantees, as the __ICCARM__ case above already does for the same reason. The wolfCrypt KAT suite and the rsa, ecc and dh unit test groups stay green on that target, so the hand-written ARM assembly does not rely on the wider alignment.
…antee on 32-bit ARM" This reverts commit 0cccfc5. The cap applies to WOLFSSL_ALIGN(x) as a whole, so it degrades every ALIGN16, ALIGN32 and ALIGN64 declaration on 32-bit ARM, not just the ones that are heap allocated. That includes buffers whose alignment is a hardware requirement rather than an optimisation: Aes.keyInit is ALIGN64 (aes.h) and ecc_key.keyRaw is ALIGN32 (ecc.h), both used for DMA on Xilinx targets, and WOLFSSL_XILINX force-enables WOLFSSL_USE_ALIGN (types.h). Silently lowering those is worse than the fault it was meant to avoid. The underlying defect is real and stands: struct Aes declares 16 byte alignment through its ALIGN16 members, while the objects are allocated with XMALLOC, which guarantees only 8 on 32-bit targets. The fix belongs in the allocation path, not in the type's declared alignment.
wolfSSL_Malloc_cb, wolfSSL_Free_cb and wolfSSL_Realloc_cb have four different signatures in memory.h, selected by WOLFSSL_STATIC_MEMORY and WOLFSSL_DEBUG_MEMORY: the static-memory forms take a heap pointer and a type, and the debug forms take the caller's function and line. The counting allocators these tests install are written to the plain (size) form, so wolfSSL_SetAllocators() does not compile once either macro is defined -- --enable-staticmemory fails the build outright. Guard them the way tests/api.c already guards der_cap_malloc_cb, on !WOLFSSL_STATIC_MEMORY && !WOLFSSL_DEBUG_MEMORY. test_pkcs7.c had the static-memory half and needed only the debug half. Builds clean now under --enable-staticmemory --enable-all, under --enable-all with WOLFSSL_DEBUG_MEMORY, and unchanged under plain --enable-all.
1a8fabb to
87b41fa
Compare
Extends the MC/DC (modified condition/decision coverage) test suites for wolfCrypt and, for the first time, the TLS protocol engine in src/.
Goals
Contents
TLS 1.3 (src/tls13.c). New API-level tests in tests/api/ covering handshake-flight boundary and fragmentation behaviour, and feature combinations with no prior test — ECH enable/disable at run time and its interaction with client authentication, session tickets and PSK; PSK key-exchange modes including psk_ke; HelloRetryRequest with an accepted cookie; post-handshake authentication, including OCSP stapling rebuilt during it; session tickets with no ticket-encryption callback; and post-handshake messages of illegal types. Plus white-box drivers in tests/unit-mcdc/ for internal helpers that no public caller can reach with the argument combinations required.
wolfCrypt. New and extended drivers across the ASN.1 and PKCS encoding paths, the SP math host and ARM backends, the classic big-integer backends, the post-quantum modules, and the smaller primitives. Several modules gain a driver for the first time. The bare-metal Cortex-M lane gains a white-box mechanism it lacked, bringing its SP, AES and PUF conditions into reach.
Fixes, each in its own commit and touching no test code:
Modules covered
asn, pkcs7, pkcs12, tsp, dsa, dh, rsa, ecc, eccsi, sakke, srp, curve25519, ed25519, ed448, lms, xmss, mldsa, mlkem, slhdsa, falcon, frodokem, aes, chacha/poly1305/chacha20-poly1305, kdf, pwdbased, wc_encrypt, puf, she, the SP math backends, the classic big-integer backends, wolfmath, wolfentropy, cr
Notes for review